<template>
  <div class="sports-view">
    <!-- 页面头部 -->
    <div class="page-header">
      <h1>运动频道</h1>
      <p>发现精彩运动内容，保持健康生活方式</p>
    </div>

    <!-- 轮播图区域 -->
    <div class="sports-carousel">
      <div class="carousel-container">
        <div class="carousel-item active">
          <img :src="wukongImg" alt="精彩体育赛事" class="carousel-img">
          <div class="carousel-caption">
            <h3>精彩体育赛事</h3>
            <p>实时直播各大体育赛事</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 快速分类导航 -->
    <div class="quick-categories">
      <div class="category-item" @click="scrollToSection('running')">
        <div class="category-icon">🏃</div>
        <span>跑步</span>
      </div>
      <div class="category-item" @click="scrollToSection('track-field')">
        <div class="category-icon">🏃‍♂️</div>
        <span>田径</span>
      </div>
      <div class="category-item" @click="scrollToSection('fitness')">
        <div class="category-icon">💪</div>
        <span>健身</span>
      </div>
      <div class="category-item" @click="scrollToSection('ball-sports')">
        <div class="category-icon">⚽</div>
        <span>球类</span>
      </div>
      <div class="category-item" @click="scrollToSection('tips')">
        <div class="category-icon">💡</div>
        <span>注意事项</span>
      </div>
      <div class="category-item" @click="scrollToSection('live')">
        <div class="category-icon">🔴</div>
        <span>直播</span>
      </div>
    </div>

    <!-- 跑步视频区域 -->
    <section id="running" class="content-section">
      <div class="section-header">
        <h2>🏃 跑步视频</h2>
        <button class="more-btn">更多 <i class="fa fa-angle-right"></i></button>
      </div>
      <div class="video-grid">
        <div v-for="video in runningVideos" :key="video.id" class="video-card">
          <div class="video-thumbnail">
            <img :src="video.thumbnail" :alt="video.title">
            <span class="video-duration">{{ video.duration }}</span>
          </div>
          <div class="video-info">
            <h3 class="video-title">{{ video.title }}</h3>
            <div class="video-meta">
              <span class="author">{{ video.author }}</span>
              <span class="views">{{ video.views }} 观看</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 田径运动区域 -->
    <section id="track-field" class="content-section">
      <div class="section-header">
        <h2>🏃‍♂️ 田径运动</h2>
        <button class="more-btn">更多 <i class="fa fa-angle-right"></i></button>
      </div>
      <div class="video-grid">
        <div v-for="video in trackFieldVideos" :key="video.id" class="video-card">
          <div class="video-thumbnail">
            <img :src="video.thumbnail" :alt="video.title">
            <span class="video-duration">{{ video.duration }}</span>
            <span v-if="video.live" class="live-badge">🔴 直播</span>
          </div>
          <div class="video-info">
            <h3 class="video-title">{{ video.title }}</h3>
            <div class="video-meta">
              <span class="author">{{ video.author }}</span>
              <span class="views">{{ video.views }} 观看</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 健身视频区域 -->
    <section id="fitness" class="content-section">
      <div class="section-header">
        <h2>💪 健身视频</h2>
        <button class="more-btn">更多 <i class="fa fa-angle-right"></i></button>
      </div>
      <div class="video-grid">
        <div v-for="video in fitnessVideos" :key="video.id" class="video-card">
          <div class="video-thumbnail">
            <img :src="video.thumbnail" :alt="video.title">
            <span class="video-duration">{{ video.duration }}</span>
          </div>
          <div class="video-info">
            <h3 class="video-title">{{ video.title }}</h3>
            <div class="video-meta">
              <span class="author">{{ video.author }}</span>
              <span class="views">{{ video.views }} 观看</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 球类运动区域 -->
    <section id="ball-sports" class="content-section">
      <div class="section-header">
        <h2>⚽ 球类运动</h2>
        <button class="more-btn">更多 <i class="fa fa-angle-right"></i></button>
      </div>
      <div class="video-grid">
        <div v-for="video in ballSportsVideos" :key="video.id" class="video-card">
          <div class="video-thumbnail">
            <img :src="video.thumbnail" :alt="video.title">
            <span class="video-duration">{{ video.duration }}</span>
            <span v-if="video.live" class="live-badge">🔴 直播</span>
          </div>
          <div class="video-info">
            <h3 class="video-title">{{ video.title }}</h3>
            <div class="video-meta">
              <span class="author">{{ video.author }}</span>
              <span class="views">{{ video.views }} 观看</span>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 运动注意事项区域 -->
    <section id="tips" class="content-section">
      <div class="section-header">
        <h2>💡 运动注意事项</h2>
      </div>
      <div class="tips-container">
        <div v-for="tip in sportsTips" :key="tip.id" class="tip-card">
          <div class="tip-icon">{{ tip.icon }}</div>
          <div class="tip-content">
            <h3 class="tip-title">{{ tip.title }}</h3>
            <p class="tip-text">{{ tip.content }}</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 实时直播区域 -->
    <section id="live" class="content-section">
      <div class="section-header">
        <h2>🔴 实时直播</h2>
        <button class="more-btn">更多 <i class="fa fa-angle-right"></i></button>
      </div>
      <div class="live-container">
        <div v-for="live in liveStreams" :key="live.id" class="live-card">
          <div class="live-thumbnail">
            <img :src="live.thumbnail" :alt="live.title">
            <div class="live-info">
              <span class="live-badge-large">🔴 LIVE</span>
              <span class="viewer-count">{{ live.viewers }} 观看</span>
            </div>
          </div>
          <div class="live-details">
            <h3 class="live-title">{{ live.title }}</h3>
            <p class="live-description">{{ live.description }}</p>
            <div class="live-author">
              <img :src="live.authorAvatar" alt="主播头像" class="author-avatar">
              <span class="author-name">{{ live.author }}</span>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import logoImg from '@/assets/logo.png'
import wukongImg from '@/assets/悟空.jpg'

export default {
  name: 'SportsView',
  data() {
    return {
      // 健身视频数据
      fitnessVideos: [
        {
          id: 1,
          title: '30分钟全身高强度训练',
          thumbnail: logoImg,
          duration: '30:45',
          author: '健身教练小王',
          views: '24.5万',
        },
        {
          id: 2,
          title: '初学者胸肌训练完整指南',
          thumbnail: logoImg,
          duration: '15:20',
          author: '健身达人小李',
          views: '18.3万',
        },
        {
          id: 3,
          title: '在家就能做的腹肌训练',
          thumbnail: logoImg,
          duration: '12:10',
          author: '健身频道',
          views: '35.7万',
        },
        {
          id: 4,
          title: '腿部训练完全手册',
          thumbnail: logoImg,
          duration: '20:30',
          author: '专业健身指导',
          views: '12.9万',
        },
        {
          id: 5,
          title: '15分钟HIIT燃脂训练',
          thumbnail: logoImg,
          duration: '15:00',
          author: '燃脂健身队',
          views: '42.1万',
        },
        {
          id: 6,
          title: '上肢力量训练计划',
          thumbnail: logoImg,
          duration: '18:45',
          author: '健身教练小张',
          views: '9.8万',
        },
      ],
      
      // 跑步视频数据
      runningVideos: [
        {
          id: 11,
          title: '初学者跑步技巧与姿势纠正',
          thumbnail: logoImg,
          duration: '10:25',
          author: '跑步教练老李',
          views: '15.6万',
        },
        {
          id: 12,
          title: '5公里跑步训练计划',
          thumbnail: logoImg,
          duration: '12:30',
          author: '马拉松达人',
          views: '22.4万',
        },
        {
          id: 13,
          title: '晨跑vs夜跑：哪个更适合你？',
          thumbnail: logoImg,
          duration: '08:40',
          author: '健康跑步频道',
          views: '18.9万',
        },
        {
          id: 14,
          title: '跑步损伤预防与恢复',
          thumbnail: logoImg,
          duration: '14:15',
          author: '运动医学专家',
          views: '11.2万',
        },
      ],
      
      // 田径运动视频数据
      trackFieldVideos: [
        {
          id: 21,
          title: '奥运会100米决赛精彩回顾',
          thumbnail: logoImg,
          duration: '05:30',
          author: '体育赛事频道',
          views: '56.8万',
        },
        {
          id: 22,
          title: '世界田径锦标赛直播',
          thumbnail: logoImg,
          duration: '正在直播',
          author: '体育直播台',
          views: '12.3万',
          live: true,
        },
        {
          id: 23,
          title: '跳高技巧教学与训练方法',
          thumbnail: logoImg,
          duration: '16:45',
          author: '田径教练',
          views: '8.7万',
        },
        {
          id: 24,
          title: '长跑冠军训练秘诀分享',
          thumbnail: logoImg,
          duration: '20:10',
          author: '国家队教练',
          views: '14.5万',
        },
      ],
      
      // 球类运动视频数据
      ballSportsVideos: [
        {
          id: 31,
          title: '世界杯足球赛精彩进球集锦',
          thumbnail: logoImg,
          duration: '12:30',
          author: '足球频道',
          views: '78.9万',
        },
        {
          id: 32,
          title: 'NBA总决赛第七场直播',
          thumbnail: logoImg,
          duration: '正在直播',
          author: '篮球直播台',
          views: '45.2万',
          live: true,
        },
        {
          id: 33,
          title: '乒乓球技巧教学：发球与接发球',
          thumbnail: logoImg,
          duration: '18:45',
          author: '乒乓球教练',
          views: '23.6万',
        },
        {
          id: 34,
          title: '网球大满贯赛事回顾',
          thumbnail: logoImg,
          duration: '15:20',
          author: '网球频道',
          views: '19.8万',
        },
        {
          id: 35,
          title: '排球比赛战术解析',
          thumbnail: logoImg,
          duration: '14:10',
          author: '排球教练',
          views: '11.3万',
        },
        {
          id: 36,
          title: '羽毛球双打技巧与配合',
          thumbnail: logoImg,
          duration: '16:30',
          author: '羽毛球世界冠军',
          views: '17.5万',
        },
      ],
      
      // 实时直播数据
      liveStreams: [
        {
          id: 41,
          title: '2023世界田径锦标赛决赛日',
          description: '全程直播各项决赛，见证新纪录的诞生',
          thumbnail: logoImg,
          viewers: '125.6万',
          author: '体育赛事直播',
          authorAvatar: logoImg,
        },
        {
          id: 42,
          title: 'NBA常规赛：湖人vs勇士',
          description: '焦点对决，詹姆斯vs库里的精彩较量',
          thumbnail: logoImg,
          viewers: '234.8万',
          author: '篮球直播频道',
          authorAvatar: logoImg,
        },
        {
          id: 43,
          title: '足球友谊赛：中国队vs韩国队',
          description: '国足精彩表现，不容错过',
          thumbnail: logoImg,
          viewers: '187.2万',
          author: '足球直播台',
          authorAvatar: logoImg,
        },
      ],
      
      // 运动注意事项数据
      sportsTips: [
        {
          id: 51,
          icon: '⚠️',
          title: '运动前热身',
          content: '每次运动前务必进行10-15分钟的热身活动，包括关节活动和轻度有氧运动，以减少运动损伤的风险。',
        },
        {
          id: 52,
          icon: '💧',
          title: '及时补水',
          content: '运动前2小时喝400-600ml水，运动中每15-20分钟补充150-250ml水，运动后根据体重损失补充水分。',
        },
        {
          id: 53,
          icon: '⏱️',
          title: '控制运动强度',
          content: '根据个人身体状况选择合适的运动强度，避免过度训练导致疲劳和损伤，遵循循序渐进的原则。',
        },
        {
          id: 54,
          icon: '👟',
          title: '选择合适装备',
          content: '穿着合适的运动鞋和服装，特别是跑步和跳跃运动，优质的装备能有效减少运动伤害。',
        },
        {
          id: 55,
          icon: '💤',
          title: '充分休息恢复',
          content: '保证充足的睡眠和休息日，肌肉需要时间修复和生长，避免连续高强度训练同一肌群。',
        },
        {
          id: 56,
          icon: '🥗',
          title: '均衡饮食营养',
          content: '运动期间注意补充足够的蛋白质、碳水化合物和维生素，为身体提供能量和修复所需的营养物质。',
        },
      ],
    }
  },
  methods: {
    // 滚动到指定区域
    scrollToSection(sectionId) {
      const section = document.getElementById(sectionId)
      if (section) {
        section.scrollIntoView({ behavior: 'smooth' })
      }
    },
  },
}
</script>

<style scoped>
.sports-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* 页面头部 */
.page-header {
  text-align: center;
  margin-bottom: 40px;
}

.page-header h1 {
  font-size: 36px;
  margin-bottom: 10px;
  color: var(--text-color);
}

.page-header p {
  font-size: 18px;
  color: var(--text-secondary-color);
}

/* 轮播图 */
.sports-carousel {
  position: relative;
  height: 400px;
  margin-bottom: 40px;
  overflow: hidden;
  border-radius: 12px;
}

.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  padding: 30px;
  color: white;
}

.carousel-caption h3 {
  font-size: 28px;
  margin-bottom: 10px;
}

.carousel-caption p {
  font-size: 18px;
}

/* 快速分类导航 */
.quick-categories {
  display: flex;
  justify-content: space-around;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 20px;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 20px;
  border-radius: 12px;
  background-color: var(--card-bg);
  transition: all 0.3s ease;
  min-width: 80px;
}

.category-item:hover {
  background-color: var(--hover-color);
  transform: translateY(-5px);
}

.category-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

/* 内容区域通用样式 */
.content-section {
  margin-bottom: 60px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 24px;
  color: var(--text-color);
}

.more-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.more-btn:hover {
  text-decoration: underline;
}

/* 视频网格 */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.video-card {
  background-color: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.video-card:hover {
  transform: translateY(-5px);
}

.video-thumbnail {
  position: relative;
  height: 150px;
  overflow: hidden;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: #ff0000;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.video-info {
  padding: 12px;
}

.video-title {
  font-size: 16px;
  margin-bottom: 8px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  display: box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary-color);
}

/* 直播卡片 */
.live-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

.live-card {
  background-color: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.live-card:hover {
  transform: translateY(-5px);
}

.live-thumbnail {
  position: relative;
  height: 220px;
  overflow: hidden;
}

.live-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-info {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.live-badge-large {
  background-color: #ff0000;
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
}

.viewer-count {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
}

.live-details {
  padding: 16px;
}

.live-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.live-description {
  font-size: 14px;
  color: var(--text-secondary-color);
  margin-bottom: 12px;
}

.live-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* 注意事项卡片 */
.tips-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.tip-card {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.tip-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.tip-content {
  flex: 1;
}

.tip-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.tip-text {
  font-size: 14px;
  color: var(--text-secondary-color);
  line-height: 1.6;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sports-view {
    padding: 10px;
  }
  
  .page-header h1 {
    font-size: 28px;
  }
  
  .sports-carousel {
    height: 200px;
  }
  
  .carousel-caption h3 {
    font-size: 20px;
  }
  
  .carousel-caption p {
    font-size: 14px;
  }
  
  .quick-categories {
    gap: 10px;
  }
  
  .category-item {
    padding: 15px;
    min-width: 60px;
  }
  
  .video-grid,
  .live-container,
  .tips-container {
    grid-template-columns: 1fr;
  }
  
  .live-thumbnail {
    height: 180px;
  }
}
</style>